"""
防治百科视图
最后修改：3.36
修改人：陈泯全
"""
from flask import Blueprint, request, json
from service.PrevenCureWikiService import prevenCureWikiService
bp = Blueprint("PrevenCureWikiSubSys", __name__, url_prefix="/PrevenCureWikiSubSys")

@bp.route('/SearchAll',methods=['GET', 'POST'])
def search():
    if request.method == 'GET':
        dname = request.args.get('querystr',type=str, default=None)
        service = prevenCureWikiService()
        ds = service.search(dname)
        dict = {}
        dict['result'] = ds
        return dict

@bp.route('/SearchSpeicesByName',methods=['GET', 'POST'])
def species():
    if request.method == 'GET':
        sname = request.args.get('sname',type=str, default=None)
        service = prevenCureWikiService()
        ds = service.speices(sname)
        dict = {}
        dict['result'] = ds
        return dict

@bp.route('/SearchDiseaseByName',methods=['GET', 'POST'])
def disease():
    if request.method == 'GET':
        dname = request.args.get('dname',type=str, default=None)
        service = prevenCureWikiService()
        ds = service.disease(dname)
        dict = {}
        dict['result'] = ds
        return dict

@bp.route('/QuerySpeices',methods=['GET', 'POST'])
def speiceslist():
    if request.method == 'GET':
        service = prevenCureWikiService()
        sl = service.speiceslist()
        t = {}
        t['data'] = sl
        return json.dumps(t, ensure_ascii=False)

@bp.route('/QueryDisease', methods=['GET', 'POST'])
def diseaselist():
    if request.method == 'GET':
        service = prevenCureWikiService()
        dl = service.diseaselist()
        t = {}
        t['data'] = dl
        return json.dumps(t,ensure_ascii=False)

@bp.route('/')
def index():

    return {
        "stuatus": 'ok'
    }